package com.imooc.project.config;

import com.imooc.project.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
//        在登陆8080时配置直接到这个路径下面
        registry.addViewController("/").setViewName("login/login");
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {   //配置拦截器
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/auth/error")
                .excludePathPatterns("/auth/logout")
                .excludePathPatterns("/")
                .excludePathPatterns("/auth/login").excludePathPatterns("/register/add");

    }
}
